package com.morningstar.qs.api.basic.common.config;

import java.io.File;
import java.io.IOException;
import java.util.logging.Logger;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.xml.sax.SAXException;

public class JavaXmlTest {
	private static Logger log=Logger.getLogger(JavaXmlTest.class.getName());
	public static void main(String...strings ) throws SAXException, IOException {
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder;
		try {
			builder = factory.newDocumentBuilder();
			Document doc = builder.parse(new File("D:/data/conf/global-env.xml"));

			Element root = doc.getDocumentElement();
			log.info(root.getTagName());
			NamedNodeMap nnm=root.getAttributes();
			log.info(nnm.getNamedItem("global-config-file").getNodeValue());
			for(int i=0; i< nnm.getLength(); i++) {
				log.info(nnm.item(i).getNodeName());
			}
		} catch (ParserConfigurationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

}
